<template>
  <div class="app-container">
    <!-- 顶部搜索 -->
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="72px"
    >
      <el-form-item label="用户名" prop="username">
        <el-input
          v-model="queryParams.username"
          placeholder="请输入用户名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="微信id" prop="wechatOpenid">
        <el-input
          v-model="queryParams.wechatOpenid"
          placeholder="请输入微信id"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="昵称" prop="nickname">
        <el-input
          v-model="queryParams.nickname"
          placeholder="请输入昵称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="手机号" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入手机号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="邮箱" prop="email">
        <el-input
          v-model="queryParams.email"
          placeholder="请输入邮箱"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="性别" prop="sex">
        <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable>
          <el-option
            v-for="dict in sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="顾客类型" prop="guestType">
        <el-select
          v-model="queryParams.guestType"
          placeholder="请选择顾客类型"
          clearable
        >
          <el-option
            v-for="dict in guest_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="组织名称" prop="orgName">
        <el-input
          v-model="queryParams.orgName"
          placeholder="请输入组织名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="组织类型" prop="orgType">
        <el-select
          v-model="queryParams.orgType"
          placeholder="请选择组织类型"
          clearable
        >
          <el-option
            v-for="dict in org_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="经办人" prop="contactPerson">
        <el-input
          v-model="queryParams.contactPerson"
          placeholder="请输入经办人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="联系电话" prop="contactPhone">
        <el-input
          v-model="queryParams.contactPhone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择状态"
          clearable
        >
          <el-option
            v-for="dict in wdm_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 按钮 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['ruoyi:guest:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ruoyi:guest:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ruoyi:guest:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['ruoyi:guest:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <!-- 表格 -->
    <el-table
      v-loading="loading"
      :data="guestList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column
        label="序号"
        type="index"
        width="60"
        align="center"
        prop="guestId"
      />
      <!-- <el-table-column label="用户名" align="center" prop="username" />
      <el-table-column label="密码" align="center" prop="password" /> -->
      <!-- <el-table-column label="微信id" align="center" prop="wechatOpenid" /> -->
      <el-table-column label="昵称" align="center" prop="nickname" />
      <el-table-column label="手机号" align="center" prop="mobile" />
      <!-- <el-table-column label="头像地址" align="center" prop="avatarUrl" width="100">
        <template #default="scope">
          <image-preview :src="scope.row.avatarUrl" :width="50" :height="50" />
        </template>
</el-table-column> -->
      <!-- <el-table-column label="邮箱" align="center" prop="email" /> -->
      <!-- <el-table-column label="性别" align="center" prop="sex">
        <template #default="scope">
          <dict-tag :options="sys_user_sex" :value="scope.row.sex" />
        </template>
      </el-table-column> -->
      <el-table-column label="顾客类型" align="center" prop="guestType">
        <template #default="scope">
          <dict-tag :options="guest_type" :value="scope.row.guestType" />
        </template>
      </el-table-column>
      <el-table-column label="组织名称" align="center" prop="orgName" />
      <el-table-column label="组织类型" align="center" prop="orgType">
        <template #default="scope">
          <dict-tag :options="org_type" :value="scope.row.orgType" />
        </template>
      </el-table-column>
      <el-table-column label="经办人" align="center" prop="contactPerson" />
      <el-table-column label="联系电话" align="center" prop="contactPhone" />
      <el-table-column
        label="最后登录时间"
        align="center"
        prop="lastLoginTime"
        width="180"
      >
        <template #default="scope">
          <span>{{ parseTime(scope.row.lastLoginTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <dict-tag :options="wdm_status" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />

      <el-table-column
        label="操作"
        align="center"
        width="320px"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleGuestInfo(scope.row)"
            v-hasPermi="['ruoyi:guest:query']"
            >查看详情</el-button
          >

          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleResetPwd(scope.row)"
            v-hasPermi="['ruoyi:guest:edit']"
            >密码重置</el-button
          >

          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['ruoyi:guest:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="primary"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['ruoyi:guest:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改顾客信息对话框 -->
    <el-dialog :title="title" v-model="open" width="55%" append-to-body>
      <el-form ref="guestRef" :model="form" :rules="rules" label-width="80px">
        <el-card class="box-card">
          <div class="clearfix" style="text-align: center">
            <span style="font-size: 20px; color: #1890ff">用户基本信息</span>
          </div>

          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item
                label="用户名"
                prop="username"
                v-if="form.guestId == null"
              >
                <el-input v-model="form.username" placeholder="请输入用户名" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="密码"
                prop="password"
                v-if="form.guestId == null"
              >
                <el-input
                  v-model="form.password"
                  type="password"
                  placeholder="请输入密码"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item label="微信id" prop="wechatOpenid">
                <el-input
                  v-model="form.wechatOpenid"
                  placeholder="请输入微信id"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="昵称" prop="nickname">
                <el-input v-model="form.nickname" placeholder="请输入昵称" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item label="手机号" prop="mobile">
                <el-input v-model="form.mobile" placeholder="请输入手机号" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入邮箱" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item label="性别" prop="sex">
                <el-select v-model="form.sex" placeholder="请选择性别">
                  <el-option
                    v-for="dict in sys_user_sex"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label-width="135px"
                label="创建时间"
                prop="createTime"
                v-if="form.guestId != null"
              >
                {{ form.createTime }}
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item label="头像地址" prop="avatarUrl">
            <image-upload v-model="form.avatarUrl" />
          </el-form-item>

          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item label="顾客类型" prop="guestType">
                <el-radio-group v-model="form.guestType">
                  <el-radio
                    v-for="dict in guest_type"
                    :key="dict.value"
                    :label="dict.value"
                    >{{ dict.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item
                label="组织类型"
                prop="orgType"
                v-if="form.guestType == 'O'"
              >
                <el-select v-model="form.orgType" placeholder="请选择组织类型">
                  <el-option
                    v-for="dict in org_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="24" class="mb8">
            <el-col :span="12">
              <el-form-item
                label="经办人"
                prop="contactPerson"
                v-if="form.guestType == 'O'"
              >
                <el-input
                  v-model="form.contactPerson"
                  placeholder="请输入经办人"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系电话"
                prop="contactPhone"
                v-if="form.guestType == 'O'"
              >
                <el-input
                  v-model="form.contactPhone"
                  placeholder="请输入联系电话"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item label="备注" prop="remark">
            <el-input
              v-model="form.remark"
              type="textarea"
              placeholder="请输入内容"
            />
          </el-form-item>
        </el-card>
        <br />
        <!-- <el-divider content-position="center">收货地址信息信息</el-divider> -->
        <el-card class="box-card">
          <div class="clearfix" style="text-align: center">
            <span style="font-size: 20px; color: #1890ff"
              >收货地址信息信息</span
            >
          </div>
          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button type="primary" icon="Plus" @click="handleAddAddress"
                >添加</el-button
              >
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="danger"
                icon="Delete"
                @click="handleDeleteAddress"
                >删除</el-button
              >
            </el-col>
          </el-row>
          <el-table
            height="30vh"
            :data="addressList"
            :row-class-name="rowAddressIndex"
            @selection-change="handleAddressSelectionChange"
            ref="address"
          >
            <el-table-column type="selection" width="50" align="center" />
            <el-table-column
              label="序号"
              align="center"
              prop="index"
              width="60"
            />
            <el-table-column label="收货人姓名" prop="deliveryName" width="150">
              <template #default="scope">
                <el-input
                  v-model="scope.row.deliveryName"
                  placeholder="请输入收货人姓名"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="收货人联系电话"
              prop="deliveryPhone"
              width="150"
            >
              <template #default="scope">
                <el-input
                  v-model="scope.row.deliveryPhone"
                  placeholder="请输入收货人联系电话"
                />
              </template>
            </el-table-column>
            <el-table-column label="省份名称" prop="province" width="150">
              <template #default="scope">
                <el-input
                  v-model="scope.row.province"
                  placeholder="请输入省份名称"
                />
              </template>
            </el-table-column>
            <el-table-column label="城市名称" prop="city" width="150">
              <template #default="scope">
                <el-input
                  v-model="scope.row.city"
                  placeholder="请输入城市名称"
                />
              </template>
            </el-table-column>
            <el-table-column label="区县名称" prop="district" width="150">
              <template #default="scope">
                <el-input
                  v-model="scope.row.district"
                  placeholder="请输入区县名称"
                />
              </template>
            </el-table-column>
            <el-table-column
              label="详细街道地址"
              prop="detailAddress"
              width="150"
            >
              <template #default="scope">
                <el-input
                  v-model="scope.row.detailAddress"
                  placeholder="请输入详细街道地址"
                />
              </template>
            </el-table-column>
            <el-table-column label="邮政编码" prop="postalCode" width="150">
              <template #default="scope">
                <el-input
                  v-model="scope.row.postalCode"
                  placeholder="请输入邮政编码"
                />
              </template>
            </el-table-column>
            <el-table-column label="是否默认" prop="isDefault" width="150">
              <template #default="scope">
                <el-select
                  v-model="scope.row.isDefault"
                  placeholder="请选择是否默认"
                >
                  <el-option
                    v-for="dict in is_default"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="地址标签" prop="addressTag" width="150">
              <template #default="scope">
                <el-select
                  v-model="scope.row.addressTag"
                  placeholder="请选择地址标签"
                >
                  <el-option
                    v-for="dict in address_tag"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="状态" prop="status" width="150">
              <template #default="scope">
                <el-select v-model="scope.row.status" placeholder="请选择状态">
                  <el-option
                    v-for="dict in wdm_status"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-form>

      <template #footer>
        <div class="dialog-footer dialog-footer-center">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 查看顾客信息详情对话框 -->
    <el-dialog
      v-model="guestInfoOpen"
      title="顾客信息详情"
      width="40%"
      append-to-body
    >
      <!-- 基础信息卡片：核心身份信息 -->
      <el-card class="mb-20">
        <el-descriptions
          column="3"
          border
          :column-props="{ lg: 3, md: 2, sm: 1 }"
        >
          <el-descriptions-item label="顾客编号">
            <span class="text-primary">{{ form.guestId }}</span>
          </el-descriptions-item>

          <el-descriptions-item label="性别">
            <el-tag type="success">{{ form.sex === "0" ? "男" : "女" }}</el-tag>
          </el-descriptions-item>
        </el-descriptions>

        <el-descriptions
          column="3"
          border
          :column-props="{ lg: 3, md: 2, sm: 1 }"
        >
          <el-descriptions-item label="联系电话">
            <span class="text-primary">{{ form.mobile }}</span>
          </el-descriptions-item>

          <el-descriptions-item label="邮箱">
            <span class="text-primary">{{ form.email }}</span>
          </el-descriptions-item>
        </el-descriptions>

        <label class="el-form-item__label">地址信息</label>
        <el-table :data="addressList">
          <el-table-column
            label="序号"
            type="index"
            width="80"
            align="center"
            prop="addressId"
          />
          <el-table-column
            label="收货人姓名"
            align="center"
            prop="deliveryName"
          />
          <el-table-column
            label="收货人联系电话"
            align="center"
            prop="deliveryPhone"
          />
          <el-table-column label="省份" align="center" prop="province" />
          <el-table-column label="城市" align="center" prop="city" />
          <el-table-column label="区县" align="center" prop="district" />
          <el-table-column
            label="详细街道地址"
            align="center"
            prop="detailAddress"
          />
          <el-table-column label="邮政编码" align="center" prop="postalCode" />
          <el-table-column label="是否默认" align="center" prop="isDefault">
            <template #default="scope">
              <dict-tag :options="is_default" :value="scope.row.isDefault" />
            </template>
          </el-table-column>
          <el-table-column label="地址标签" align="center" prop="addressTag">
            <template #default="scope">
              <dict-tag :options="address_tag" :value="scope.row.addressTag" />
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </el-dialog>
  </div>
</template>

<script setup name="Guest">
import {
  listGuest,
  getGuest,
  delGuest,
  addGuest,
  updateGuest,
  resetGuestPwd,
} from "@/api/ruoyi/guest";
import { listAddress } from "@/api/ruoyi/address";
import { loadAllParams } from "@/api/page";

const { proxy } = getCurrentInstance();
const {
  org_type,
  wdm_status,
  is_default,
  guest_type,
  address_tag,
  sys_user_sex,
  del_flag,
} = proxy.useDict(
  "org_type",
  "wdm_status",
  "is_default",
  "guest_type",
  "address_tag",
  "sys_user_sex",
  "del_flag"
);

const guestList = ref([]);
const addressList = ref([]);

const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const checkedAddress = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    username: null,
    wechatOpenid: null,
    nickname: null,
    mobile: null,
    email: null,
    sex: null,
    guestType: null,
    orgName: null,
    orgType: null,
    contactPerson: null,
    contactPhone: null,
    status: null,
  },
  rules: {
    username: [{ required: true, message: "用户名不能为空", trigger: "blur" }],
    password: [{ required: true, message: "密码不能为空", trigger: "blur" }],
    mobile: [
      { required: true, message: "手机号不能为空", trigger: "blur" },
      {
        pattern:
          /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/, // 覆盖所有运营商号段
        message: "请输入正确的11位手机号",
        trigger: "blur",
      },
    ],
    // mobile: [{ required: true, message: "手机号不能为空", trigger: "blur" }],
    email: [{ required: true, message: "邮箱不能为空", trigger: "blur" }],
  },
});

const { queryParams, form, rules } = toRefs(data);

/** 查询顾客信息列表 */
function getList() {
  loading.value = true;
  listGuest(queryParams.value).then((response) => {
    // guestList.value = response.rows;
    // 过滤已删除数据（假设 delFlag 字段标识删除状态）
    guestList.value = response.rows.filter(
      (item) => item.delFlag !== "2"
    );
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    guestId: null,
    username: null,
    password: null,
    wechatOpenid: null,
    nickname: null,
    mobile: null,
    avatarUrl: null,
    email: null,
    sex: null,
    guestType: null,
    orgName: null,
    orgType: null,
    contactPerson: null,
    contactPhone: null,
    lastLoginTime: null,
    status: null,
    delFlag: null,
    version: null,
    createTime: null,
    updateTime: null,
    createBy: null,
    updateBy: null,
    remark: null,
  };
  addressList.value = [];
  proxy.resetForm("guestRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.guestId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加顾客信息";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _guestId = row.guestId || ids.value;
  getGuest(_guestId).then((response) => {
    form.value = response.data;
    addressList.value = response.data.addressList;
    open.value = true;
    title.value = "修改顾客信息";
  });
}

/** 查看顾客信息详情按钮操作 */
const guestInfoOpen = ref(false);
// const addressList = ref([])

function handleGuestInfo(row) {
  reset();
  const _guestId = row.guestId;
  getGuest(_guestId).then((response) => {
    form.value = response.data;
    guestInfoOpen.value = true;
  });
  
  //  获取顾客地址信息
  loadAllParams.addressId = row.guestId;
  listAddress(loadAllParams).then((response) => {
    addressList.value = response.rows;
  });
  guestInfoOpen.value = true;
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["guestRef"].validate((valid) => {
    if (valid) {
      form.value.addressList = addressList.value;
      if (form.value.guestId != null) {
        updateGuest(form.value).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addGuest(form.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _guestIds = row.guestId || ids.value;
  proxy.$modal
    .confirm('是否确认删除顾客信息编号为"' + _guestIds + '"的数据项？')
    .then(function () {
      return delGuest(_guestIds);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}

// 重置密码操作
function handleResetPwd(row) {
  const _guestId = row.guestId;
  proxy.$modal
    .confirm("是否确认修改顾客的密码信息？")
    .then(function () {
      return resetGuestPwd(_guestId);
    })
    .then(() => {
      proxy.$modal.msgSuccess("密码重置成功");
    })
    .catch(() => {});
}

/** 收货地址信息序号 */
function rowAddressIndex({ row, rowIndex }) {
  row.index = rowIndex + 1;
}

/** 收货地址信息添加按钮操作 */
function handleAddAddress() {
  let obj = {};
  obj.deliveryName = "";
  obj.deliveryPhone = "";
  obj.province = "";
  obj.city = "";
  obj.district = "";
  obj.detailAddress = "";
  obj.postalCode = "";
  obj.isDefault = "";
  obj.addressTag = "";
  obj.status = "";
  obj.remark = "";
  addressList.value.push(obj);
}

/** 收货地址信息删除按钮操作 */
function handleDeleteAddress() {
  if (checkedAddress.value.length == 0) {
    proxy.$modal.msgError("请先选择要删除的收货地址信息数据");
  } else {
    const addresss = addressList.value;
    const checkedAddresss = checkedAddress.value;
    addressList.value = addresss.filter(function (item) {
      return checkedAddresss.indexOf(item.index) == -1;
    });
  }
}

/** 复选框选中数据 */
function handleAddressSelectionChange(selection) {
  checkedAddress.value = selection.map((item) => item.index);
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "ruoyi/guest/export",
    {
      ...queryParams.value,
    },
    `guest_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>

<style scoped>
.dialog-footer-center {
  text-align: center;
}
</style>
